Skip to content

feat(miner-selfimprove): wire the historical-replay scorer into the Phase 7 calibration loop (#4248) - #5462

Merged
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
andriypolanski:feat/miner-phase7-calibration-runner-4248
Jul 12, 2026
Merged

feat(miner-selfimprove): wire the historical-replay scorer into the Phase 7 calibration loop (#4248)#5462
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
andriypolanski:feat/miner-phase7-calibration-runner-4248

Conversation

@andriypolanski

@andriypolanski andriypolanski commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #4248.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • Run the full gate with npm run test:ci (and npm run test:coverage unsharded) under Node 22 (.nvmrc) before pushing. The development sandbox runs Node 18 without the workspace node_modules (the engine's dist/ is unbuilt and node:sqlite is unavailable), so the Vitest gate could not be executed here. The new module's pure logic was verified out-of-band with a standalone Node script against the real replay-objective-anchor.js scorer (composite of a fully-overlapping feature task = 1.0; combined with a 0.8 pr_outcome at default 0.5/0.5 weights = 0.9) and against verbatim copies of the snapshot/normalize helpers (every accept/reject/fallback branch).
  • Codecov surface: only packages/gittensory-miner/lib/calibration-run.js is measured (packages/gittensory-miner/lib/**); the .d.ts, package.json, docs, and test/** are not. calibration-run.js is written to be pure and dependency-injected, and test/unit/miner-calibration-run.test.ts targets 100% of its lines and branches (both sides of every guard, ??, and default parameter), with the integration test covering the default engine-combine + real-ledger paths.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed. The persisted snapshot surfaces only accuracies, the documented baseline, hold-reason codes, and provenance — never raw replay scores or rewards.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. (None in this PR.)
  • API/OpenAPI/MCP behavior is updated and tested where needed. (No API/OpenAPI/MCP surface changed; the snapshot is queryable via the existing ledger list --type path.)
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. (No UI changes.)
  • Visible UI changes include a UI Evidence section below. (Not applicable — no UI changes.)
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs. (CHANGELOG.md untouched.)

UI Evidence

Not applicable — this change is a miner-package runtime module + tests + package docs (Markdown). No rendered frontend surface changed.

Notes

  • Design boundary respected. computePhase7CalibrationLoop is a pure engine contract that cannot depend on the miner (miner → engine, not the reverse), so it correctly waited for an external caller. This runner is that caller and lives on the miner side; it measures and records only. Acting on the combined accuracy — the calibration-gated circuit-breaker — remains maintainer-only (maintainer: wire calibration accuracy into the live auto-tune circuit-breaker for miner-originated PRs #2352), as documented in docs/miner-selfimprove-calibration.md.
  • Fail-closed preserved. A degraded/unavailable replay harness flows through verbatim to the engine, whose fail-closed hold path blocks any autonomy increase even when pr_outcome has signal; the integration test pins this.
  • Persistence pattern. The calibration_snapshot typed event mirrors pr-outcome.js's MINER_PR_OUTCOME_EVENT over the shared append-only event-ledger.js, so it inherits the ledger's immutability/JSON-verbatim guarantees and is immediately queryable with gittensory-miner ledger list --type calibration_snapshot.

@andriypolanski
andriypolanski marked this pull request as draft July 12, 2026 20:41
@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 12, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb

loopover-orb Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-12 20:49:03 UTC

7 files · 2 AI reviewers · no blockers · readiness 100/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds the missing miner-side runner connecting the deterministic replay scorer to the engine's Phase7 calibration combine, persisting results as a typed event-ledger row exactly mirroring the existing pr-outcome.js pattern. The wiring is traced end-to-end in the integration test against the real engine combine and a real temp-file SQLite ledger, and the fail-closed degraded-harness case is exercised correctly (autonomyIncreasePermitted false, snapshot still persisted). The module is read/measure-only as claimed — no autonomy or threshold mutation paths are present — and the composite score correctly returns null rather than a fabricated 0 when there are no scorable tasks.

Nits — 5 non-blocking
  • packages/gittensory-miner/lib/calibration-run.js:120 — normalizeCalibrationSnapshotPayload has ~14 branches (threshold 10); consider extracting the per-field validators into a small table/loop for readability.
  • packages/gittensory-miner/lib/calibration-run.js:53 — scoreHistoricalReplayComposite nests to depth 5; an early-continue restructure would flatten the loop body.
  • packages/gittensory-miner/lib/calibration-run.js — the runner silently swallows a malformed snapshot when a ledger IS injected (recorded stays null with no signal to the caller); consider at least logging or surfacing that case since it means a calibration cycle silently fails to persist.
  • Extract the repeated isFiniteNumber/optionalString-guard pattern in normalizeCalibrationSnapshotPayload into a small declarative field-spec to shrink the complexity flagged above.
  • Consider whether recordCalibrationSnapshot returning null on a malformed payload should also emit a warning, since currently a caller has no way to distinguish 'not persisted because malformed' from any other silent no-op.
Signal Result Evidence
Code review ✅ No blockers 2 reviewers, synthesized
Linked issue ✅ Linked #4248
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 155 registered-repo PR(s), 105 merged, 29 issue(s).
Contributor context ✅ Confirmed Gittensor contributor andriypolanski; Gittensor profile; 155 PR(s), 29 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence. LLM value judgment: moderate — The diff directly closes the stated wiring gap by connecting existing replay scoring and engine combine logic to a queryable persisted snapshot without adding new command surface.
Review context
  • Author: andriypolanski
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 155 PR(s), 29 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
[BETA] Chat with Gittensory

Ask Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @gittensory ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @gittensory chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @gittensory mention with a real question is routed to the closest matching read-only command automatically -- no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.71%. Comparing base (30a6ffb) to head (bdf618c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5462      +/-   ##
==========================================
+ Coverage   94.52%   94.71%   +0.18%     
==========================================
  Files         554      555       +1     
  Lines       44469    44526      +57     
  Branches    14666    14666              
==========================================
+ Hits        42034    42172     +138     
+ Misses       1754     1619     -135     
- Partials      681      735      +54     
Flag Coverage Δ
shard-1 43.89% <0.00%> (-0.18%) ⬇️
shard-2 35.17% <100.00%> (+0.17%) ⬆️
shard-3 31.65% <0.00%> (-0.35%) ⬇️
shard-4 31.80% <92.98%> (+0.11%) ⬆️
shard-5 32.85% <0.00%> (+0.14%) ⬆️
shard-6 44.05% <0.00%> (+0.51%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/gittensory-miner/lib/calibration-run.js 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andriypolanski
andriypolanski marked this pull request as ready for review July 12, 2026 20:47

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gittensory approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 7e2e20d into JSONbored:main Jul 12, 2026
16 checks passed
@andriypolanski
andriypolanski deleted the feat/miner-phase7-calibration-runner-4248 branch July 16, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(miner-selfimprove): wire the historical-replay scorers into the Phase 7 calibration loop

2 participants